package com.yanqu.road.server.cmd.activity.dragonboatrace;

import com.yanqu.road.entity.union.UnionBaseInfo;
import com.yanqu.road.logic.pb.UnionBasePb;
import com.yanqu.road.pb.dragonboatrace.DragonBoatRaceProto;
import com.yanqu.road.pb.union.UnionProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.dragonboatrace.DragonBoatRaceMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;

/**
 * @Description
 * @Author cwq
 * @Data 2022/2/15 16:56
 */
@Cmd(code = CrossProtocol.C2_DRAGONBOATRACE_SYN_UNION_INFO, desc = "同步联盟信息")
public class CrossDragonBoatRaceSynUnionInfoCmd extends CrossCommand {

    int activityId;
    String unionId;
    int type;
    UnionBaseInfo unionBase;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        DragonBoatRaceProto.DragonBoatRaceSynUnionInfoGameToCrossMsg builder = DragonBoatRaceProto.DragonBoatRaceSynUnionInfoGameToCrossMsg.parseFrom(packet.getBytes());
        activityId = builder.getActivityId();
        unionId = builder.getUnionId();
        type = builder.getType();
        unionBase = UnionBasePb.parseUnionBaseInfo(builder.getUnionBase());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        DragonBoatRaceMgr.synUnionInfo(activityId, unionId, type, unionBase);
    }

    @Override
    public void sendData() {

    }
}
